
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"
	xmlns:c="http://java.sun.com/jsp/jstl/core">

<ui:composition template="/template_padrao.xhtml">

	<ui:define name="content">

		<f:event type="preRenderView"
            listener="#{fornecedorMaterialMB.beginConversation()}" />

		
		<h2>Consulta Materiais</h2>
		
		<h:form id="form_con_materiais">
			
			<p:fieldset styleClass="fieldSetPadrao">
				<legend>Pesquisa</legend>
				<div id="actionButton" class="buttonNew">
					<p:commandButton value="Novo" action="#{materialMB.novo()}"	ajax="false" />
				</div>
				
				<br />
				<table class="table">
					<tr>
						<td> <h:outputLabel value="Material" /></td>
						<td> <p:inputText value="#{materialMB.descricaoMaterialPesquisa}" /> </td>
					</tr>
					
					<tr>	
						<td>			
							<p:commandButton value="Buscar" action="#{materialMB.pesquisar()}"
							ajax="false" />
						</td>
					</tr>
				</table>
			</p:fieldset>
						
			<br />
			
			<p:dataTable value="#{materialMB.listaMateriais}" 
						var="material"  
						paginator="true" 
						rows="10" 
						paginatorPosition="bottom" 
						id="table_list_materiais" 
						rendered="#{materialMB.listaMateriais.size() > 0}"> 
  
				<p:column>
					<f:facet name="header">
						<h:outputText value="Código" />
					</f:facet>
					
					<h:outputText value="#{material.id}"/>
					
				</p:column>
				
				<p:column>
					<f:facet name="header">
						<h:outputText value="Descrição" />
					</f:facet>
					<h:outputText value="#{material.descricaoMaterial}" />
				</p:column>
				
				<p:column>
					<f:facet name="header">
						<h:outputText value="Unidade Medida" />
					</f:facet>
					<h:outputText value="#{material.unidadeMedida.toString()}" />					
				</p:column>

				
				<p:column>
					<f:facet name="header">
						<h:outputText value="Ações" />
					</f:facet>
					
					<h:commandLink action="#{materialMB.editar()}" title="Editar" >					
						<f:setPropertyActionListener target="#{materialMB.materialSelecinado}" value="#{material}" />
						<h:graphicImage value="/images/editar.png" styleClass="buttonEditDeletSearch"/>
					</h:commandLink>
					
					<p:commandLink  oncomplete="cdRemoveMaterial.show()" title="Excluir" >    					
    					<f:setPropertyActionListener target="#{materialMB.materialSelecinado}" value="#{material}" />
    					<h:graphicImage value="/images/excluir.png" styleClass="buttonEditDeletSearch"/>
    				</p:commandLink>   				
					
				</p:column>
			</p:dataTable>

		</h:form>

		<h:form>
          <p:confirmDialog message="Deseja realmente excluir?"  
                             header="Excluir"  
                             severity="alert"  
                             modal="true"  
                             widgetVar="cdRemoveMaterial">  
                <p:outputPanel>  
                    <h:form>  
                        <p:commandButton action="#{materialMB.deletar()}"                                          
                                         value="Sim"  
                                         process="@this"  
                                         oncomplete="cdRemoveMaterial.hide()"
                                         ajax="false">                                           
                        </p:commandButton>  
                        <p:commandButton value="Não" oncomplete="cdRemoveMaterial.hide()"/>  
                    </h:form>  
                </p:outputPanel>  
            </p:confirmDialog>		
		</h:form>

	</ui:define>

</ui:composition>

</html>